package com.es.www.second;

import java.math.BigDecimal;

import com.es.www.first.PurchaseRequest;
import com.es.www.second.factory.PipelineFactory;

/**
 * @Created by michangtao
 * @Date 2022/5/25 11:38
 * @Description
 */
public class Client {

    public static void main(String[] args) {
        Pipeline pipeline = PipelineFactory.getPipeline();
        /**
         * 从头节点循环执行每一个handler，直到被某个handler处理
         * DefaultHandler ==> DepartmentHandler ==> CollegeHandler ==> SchoolHandler ==> DefaultTailHandler
         *
         */
        AbstractHandler handler = pipeline.getHead();
        do{
            if(handler == null){
                pipeline.clear();
                break;
            }
            handler.process();
            //赋值下一个执行器
            handler = handler.nextHandler;
        }while(handler != pipeline.getTail());
    }
}
